#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int mu[N];
int minP[N];
vector<int> p;
int cnt[N];
long long cnt1[N];
int main(){
    int n;
    cin>>n;
    int ma = 0;
    for(int i = 1;i<=n;i++){
        int x;
        cin>>x;
        ma = max(ma,x);
        cnt[x]++;
    }
    mu[1] = 1;
    for(int i = 2;i<=ma;i++){
        if(!minP[i]){
            minP[i] = i;
            mu[i] = -1;
            p.push_back(i);
        }
        for(int j = 0;minP[i] != p[j] && 1ll*i * p[j] <= ma;j++){
            minP[i * p[j]] = p[j];
            mu[i * p[j]] = -mu[i];
        }
        if(1ll*minP[i] * i <= ma){
            minP[i * minP[i]] = minP[i];
        }
    }
    for(int i = 1;i <= ma;i++){
        int val = 0;
        for(int j = i;j <= ma;j += i){
            val += cnt[j];
        }
        for(int j = i;j <= ma;j += i){
            cnt1[j] += val*mu[i];
        }
    }
    cnt1[1] -= 1;
    long long tot1 = 0,tot2 = 0;
    for(int i = 1;i <= ma;i++){
        tot1 += 1ll*cnt[i]*cnt1[i];
        tot2 += 1ll*cnt[i]*cnt1[i]*(cnt1[i] - 1)/2;
    }
    tot1/=2;
    tot1 *= (n - 2);
    //cerr<<tot1<<' '<<tot2<<'\n';
    cout<<1ll*n*(n - 1)*(n - 2)/6 - (tot1 - tot2)<<'\n';
}
